﻿@model CustomerAddressListModel
@using Nop.Web.Models.Customer;
@{
    Layout = "~/Views/Shared/_Root.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Account").Text);
}
<div class="page account-page address-list-page">
    <div class="page-title">
        <h1>@T("Account.CustomerAddresses")</h1>
    </div>
    <div class="page-body">
        <div class="add-button">
            <a href="@Url.RouteUrl("CustomerAddressAdd")" data-role="button">@T("Common.AddNew")</a>
        </div>
        <div class="address-list">
            @if (Model.Addresses.Count > 0)
            {
                <ul data-role="listview" data-inset="true" data-filter="false">
                    @for (int i = 0; i < Model.Addresses.Count; i++)
                    {
                        var address = Model.Addresses[i];
                        
                        <li>
                            <div class="address-item">
                                <div>
                                    <div class="name">
                                        <strong>@address.FirstName @address.LastName</strong>
                                    </div>
                                    <div class="email">
                                        @Html.LabelFor(model => model.Addresses[i].Email):
                                        @address.Email
                                    </div>
                        @if (address.PhoneEnabled)
                        {
                                    <div class="phone">
                                        @Html.LabelFor(model => model.Addresses[i].PhoneNumber):
                                        @address.PhoneNumber
                                    </div>
                        }
                        @if (address.FaxEnabled)
                        {
                                    <div class="fax">
                                        @Html.LabelFor(model => model.Addresses[i].FaxNumber):
                                        @address.FaxNumber
                                    </div>
                        }
                                    @if (address.CompanyEnabled && !String.IsNullOrEmpty(address.Company))
                                    {
                                        <div class="company">
                                            @address.Company
                                        </div>
                                    }
                        @if (address.StreetAddressEnabled)
                        {
                            <div class="address1">
                                @address.Address1
                            </div>
                        }
                                    @if (address.StreetAddress2Enabled && !String.IsNullOrEmpty(address.Address2))
                                    {
                                        <div class="address2">
                                            @address.Address2
                                        </div>
                                    }
                        @if (address.CityEnabled || address.StateProvinceEnabled || address.ZipPostalCodeEnabled)
                        {
                            <div class="city-state-zip">
                                @if (address.CityEnabled)
                                {
                                    @address.City
                                }
                                @if (address.CityEnabled && (address.StateProvinceEnabled || address.ZipPostalCodeEnabled))
                                {
                                    <text>,</text>
                                }
                                @if (address.StateProvinceEnabled)
                                {
                                    @address.StateProvinceName
                                }
                                @if (address.ZipPostalCodeEnabled)
                                {
                                    @address.ZipPostalCode
                                }

                            </div>
                        }
                        @if (address.CountryEnabled && !String.IsNullOrEmpty(address.CountryName))
                        {
                                        <div class="country">
                                            @address.CountryName
                                        </div>
                                    }
                                </div>
                                <div class="buttons">
                                    <a href="@Url.RouteUrl("CustomerAddressEdit", new { addressId = address.Id })" data-role="button">@T("Common.Edit")</a>
                                    <a href="@Url.RouteUrl("CustomerAddressDelete", new { addressId = address.Id })" data-role="button">@T("Common.Delete")</a>
                                </div>
                            </div>
                        </li>
                    }
                </ul>
            }
            else
            {
                @T("Account.CustomerAddresses.NoAddresses")
            }
        </div>
    </div>
</div>
